function(add_aace_library libname)
    PROJECT_TARGET_ADD(${libname})
    # Use IMPORTED_LOCATION_RELEASE as a bundled library
    get_target_property(imppath ${libname} IMPORTED_LOCATION_RELEASE)
    # Set LABELS and IMPORTED_LOCATION for AGL app-templates
    set_target_properties(${libname} PROPERTIES
        LABELS LIBRARY
        IMPORTED_LOCATION ${imppath}
    )
endfunction()


add_aace_library(AACECarControlEngine)
add_aace_library(AACECarControlPlatform)
add_aace_library(AACECoreEngine)
add_aace_library(AACECorePlatform)
add_aace_library(AACEAlexaEngine)
add_aace_library(AACEAlexaPlatform)
add_aace_library(AACECBLEngine)
add_aace_library(AACECBLPlatform)
add_aace_library(AACEContactUploaderEngine)
add_aace_library(AACEContactUploaderPlatform)
add_aace_library(AACENavigationEngine)
add_aace_library(AACENavigationPlatform)
add_aace_library(AACEPhoneControlEngine)
add_aace_library(AACEPhoneControlPlatform)

function(add_avs_library libname imppath)

    PROJECT_TARGET_ADD(${libname})
    add_library(${libname} SHARED IMPORTED GLOBAL)
    # Set LABELS and IMPORTED_LOCATION for AGL app-templates

    get_filename_component(realname ${imppath} REALPATH)
    get_filename_component(basename ${imppath} NAME)

    set_target_properties(${libname} PROPERTIES
        IMPORTED_LOCATION ${realname}
    )

    configure_file( ${realname} ${CMAKE_BINARY_DIR}/package/lib/${basename} COPYONLY)

endfunction()

add_avs_library(ACL ${AAC_HOME}/lib/libACL.so)
add_avs_library(ADSL ${AAC_HOME}/lib/libADSL.so)
add_avs_library(AFML ${AAC_HOME}/lib/libAFML.so)
add_avs_library(AIP ${AAC_HOME}/lib/libAIP.so)
add_avs_library(Alerts ${AAC_HOME}/lib/libAlerts.so)
add_avs_library(Alexa ${AAC_HOME}/lib/libAlexa.so)
add_avs_library(ApiGateway ${AAC_HOME}/lib/libApiGateway.so)
add_avs_library(AudioPlayer ${AAC_HOME}/lib/libAudioPlayer.so)
add_avs_library(AudioResources ${AAC_HOME}/lib/libAudioResources.so)
add_avs_library(AVSCommon ${AAC_HOME}/lib/libAVSCommon.so)
add_avs_library(AVSGatewayManager ${AAC_HOME}/lib/libAVSGatewayManager.so)
add_avs_library(AVSSystem ${AAC_HOME}/lib/libAVSSystem.so)
add_avs_library(Bluetooth ${AAC_HOME}/lib/libBluetooth.so)
add_avs_library(CapabilitiesDelegate ${AAC_HOME}/lib/libCapabilitiesDelegate.so)
add_avs_library(Captions ${AAC_HOME}/lib/libCaptions.so)
add_avs_library(CaptionsLib ${AAC_HOME}/lib/libCaptionsLib.so)
add_avs_library(CBLAuthDelegate ${AAC_HOME}/lib/libCBLAuthDelegate.so)
add_avs_library(CertifiedSender ${AAC_HOME}/lib/libCertifiedSender.so)
add_avs_library(ContextManager ${AAC_HOME}/lib/libContextManager.so)
add_avs_library(DeviceSettings ${AAC_HOME}/lib/libDeviceSettings.so)
add_avs_library(DoNotDisturbCA ${AAC_HOME}/lib/libDoNotDisturbCA.so)
add_avs_library(Endpoints ${AAC_HOME}/lib/libEndpoints.so)
add_avs_library(Equalizer ${AAC_HOME}/lib/libEqualizer.so)
add_avs_library(EqualizerImplementations ${AAC_HOME}/lib/libEqualizerImplementations.so)
add_avs_library(ExternalMediaPlayer ${AAC_HOME}/lib/libExternalMediaPlayer.so)
add_avs_library(InteractionModel ${AAC_HOME}/lib/libInteractionModel.so)
add_avs_library(KWD ${AAC_HOME}/lib/libKWD.so)
add_avs_library(ModeController ${AAC_HOME}/lib/libModeController.so)
add_avs_library(MRM ${AAC_HOME}/lib/libMRM.so)
add_avs_library(Notifications ${AAC_HOME}/lib/libNotifications.so)
add_avs_library(OpusEncoderContext ${AAC_HOME}/lib/libOpusEncoderContext.so)
add_avs_library(PlaybackController ${AAC_HOME}/lib/libPlaybackController.so)
add_avs_library(PlaylistParser ${AAC_HOME}/lib/libPlaylistParser.so)
add_avs_library(PowerController ${AAC_HOME}/lib/libPowerController.so)
add_avs_library(RangeController ${AAC_HOME}/lib/libRangeController.so)
add_avs_library(RegistrationManager ${AAC_HOME}/lib/libRegistrationManager.so)
add_avs_library(SpeakerManager ${AAC_HOME}/lib/libSpeakerManager.so)
add_avs_library(SpeechEncoder ${AAC_HOME}/lib/libSpeechEncoder.so)
add_avs_library(SpeechSynthesizer ${AAC_HOME}/lib/libSpeechSynthesizer.so)
add_avs_library(SQLiteStorage ${AAC_HOME}/lib/libSQLiteStorage.so)
add_avs_library(SystemSoundPlayer ${AAC_HOME}/lib/libSystemSoundPlayer.so)
add_avs_library(TemplateRuntime ${AAC_HOME}/lib/libTemplateRuntime.so)
add_avs_library(ToggleController ${AAC_HOME}/lib/libToggleController.so)
add_avs_library(curl ${AAC_HOME}/lib/libcurl.so.4)
add_avs_library(nghttp2 ${AAC_HOME}/lib/libnghttp2.so.14)
add_avs_library(opus ${AAC_HOME}/lib/libopus.so.0)
add_avs_library(sqlite3 ${AAC_HOME}/lib/libsqlite3.so.0)

if(EXISTS ${AAC_HOME}/lib/libpryon_lite.so.1.13)
    add_aace_library(AACEAmazonLiteEngine)
    add_avs_library(AMAZONLITE ${AAC_HOME}/lib/libAMAZONLITE.so)
    add_avs_library(KeywordDetectorProvider ${AAC_HOME}/lib/libKeywordDetectorProvider.so)
    add_avs_library(pryon_lite ${AAC_HOME}/lib/libpryon_lite.so.1.13)
endif()

if(EXISTS ${AAC_HOME}/share/cmake/AACESystemAudio.cmake)
    add_aace_library(AACESystemAudioEngine)
endif()

if(EXISTS ${AAC_HOME}/share/cmake/AACELocalVoiceControl.cmake)
    add_aace_library(AACELocalVoiceControlEngine)
    add_aace_library(AACELocalVoiceControlPlatform)
    add_avs_library(libHybridProxy ${AAC_HOME}/lib/libHybridProxy.so)
    add_avs_library(libahe_logger ${AAC_HOME}/lib/libahe_logger.so)
    add_avs_library(libahe_platform_interfaces ${AAC_HOME}/lib/libahe_platform_interfaces_ipc.so)
    add_avs_library(libboost_atomic ${AAC_HOME}/lib/libboost_atomic.so.1.68.0)
    add_avs_library(libboost_chrono ${AAC_HOME}/lib/libboost_chrono.so.1.68.0)
    add_avs_library(libboost_date_time ${AAC_HOME}/lib/libboost_date_time.so.1.68.0)
    add_avs_library(libboost_filesystem ${AAC_HOME}/lib/libboost_filesystem.so.1.68.0)
    add_avs_library(libboost_program_options ${AAC_HOME}/lib/libboost_program_options.so.1.68.0)
    add_avs_library(libboost_system ${AAC_HOME}/lib/libboost_system.so.1.68.0)
    add_avs_library(libboost_thread ${AAC_HOME}/lib/libboost_thread.so.1.68.0)
    add_avs_library(libnanomsg ${AAC_HOME}/lib/libnanomsg.so.5.1.0)

    if(EXISTS ${AAC_HOME}/share/cmake/AACELocalSkillService.cmake)
        add_aace_library(AACELocalSkillServiceEngine)
        add_aace_library(AACELocalSkillServicePlatform)
        if(EXISTS ${AAC_HOME}/share/cmake/AACECarControlLocalService.cmake)
            add_aace_library(AACECarControlLocalServiceEngine)
        endif()
        if(EXISTS ${AAC_HOME}/share/cmake/AACEAddressBookLocalServiceEngine.cmake)
            add_aace_library(AACEAddressBookLocalServiceEngine)
            add_aace_library(AACEAddressBookEngine)
            add_aace_library(AACEAddressBookPlatform)
        endif()
    endif()
endif()